<% provide(:title, '编辑文章'+@post.title) %>
<script src="https://cdn.bootcdn.net/ajax/libs/showdown/1.9.1/showdown.min.js"></script>
<div class="concard noflex nobgc">
<div class="form">
<div class="fti">编辑文章</div>
<% if logged_in? && current_user.admin? %>
<%= form_with(model: @post, local: true) do |f| %>
<div class="field">
<div id="newti"><%= f.label :title ,"标题" ,id:"ntil" %><%= f.text_field :title ,id:"ntif",value:@post.title %></div>
<div id="newcon">
<%= f.text_area :content, placeholder: "编辑文章" , onkeyup:"javascript:md();"%>
<%= f.text_area :content_html,style:"display:none"%>
<div id="pre"></div>
</div>
<div id="tag">
<span>标签：</span><input value="<%= @post.tag_id %>" disabled= "disabled" id="ntag">
</div>
</div>
<%= f.submit "发布", class: "btn btn-primary" %>
<% end %>
<% else %>
权限不足
<% end %>
</div>
</div>

<script type="text/javascript">
    var converter = new showdown.Converter();
    function md() {
        text = document.getElementById("post_content").value;
        html = converter.makeHtml(text)
        document.getElementById("post_content_html").value = html;
        document.getElementById("pre").innerHTML = html
    }

</script>